package com.qqtech.qquan.user.dao;

import java.math.BigDecimal;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import com.qqtech.core.common.util.BeanUtil;
import com.qqtech.core.frame.dao.BaseDaoImpl;
import com.qqtech.qquan.user.model.UserWithdraw;
import com.qqtech.qquan.user.model.UserWithdrawQuery;
import com.qqtech.qquan.user.model.UserWithdrawVo;

@Repository
public class UserWithdrawDaoImpl extends BaseDaoImpl<UserWithdraw>implements UserWithdrawDao {
	public static final Logger log = LoggerFactory.getLogger(UserWithdrawDaoImpl.class);

	@Override
	public List<UserWithdraw> getHandleMoney(UserWithdrawVo userWithdrawVo) {
		return sqlSessionTemplate.selectList(getSqlName("selectHandle"), userWithdrawVo);
	}
	
	@Override
	public int queryCountAdmin(UserWithdrawQuery query) {
		return sqlSessionTemplate.selectOne(getSqlName("selectCountAdmin"), BeanUtil.toMap(query));
	}
	
	@Override
	public Page<UserWithdrawVo> queryPageListAdmin(UserWithdrawQuery query, Pageable pageable) {
		List<UserWithdrawVo> contentList = sqlSessionTemplate.selectList(getSqlName("selectAdmin"),
				getParams(query, pageable));
		return new PageImpl<UserWithdrawVo>(contentList, pageable, this.queryCountAdmin(query));
	}
	
	public List<UserWithdrawVo> queryList4Excel(UserWithdrawQuery query, Pageable pageable){
		return sqlSessionTemplate.selectList(getSqlName("selectAdmin"), getParams(query, pageable));
	}
	
	@Override
	public BigDecimal querySumCash(UserWithdrawQuery query) {
		return sqlSessionTemplate.selectOne(getSqlName("selectSumCash"), BeanUtil.toMap(query));
	}
}
